
#ifndef EVALOUTPUTLISTENER_H_
#define EVALOUTPUTLISTENER_H_

#include "../Interface/OutputListener.h"

#include <fstream>
#include <iostream>
#include <set>
#include "../Packets/PubPkt.h"
#include "Producer.h"

using namespace std;

/**
 * The OutputListener used for evaluation: it stores the number of received complex events
 * on a local variable, and provides methods to write it on a file.
 */
class EvalOutputListener: public OutputListener {
public:

	EvalOutputListener();

	virtual ~EvalOutputListener();

	void handleOutput(Outbox &outbox, double procTime);

	/**
	 * Reset the total amount of received events
	 */
	void reset() {
		detectedEvents = 0;
		processingTime = 0;
		numCalls = 0;
	}

	/**
	 * Prints collected results on the given file.
	 * The label is written on the left of the written result (for faster processing).
	 * If newLine, starts writing on a new line.
	 * If printLabel, prints label before writing.
	 */
	void printToFile(std::string label, char const *fileName, bool newLine, bool printLabel);

	/**
	 * Prints the mean processing time.
	 * The label is written on the left of the written result (for faster processing).
	 * If newLine, starts writing on a new line.
	 * If printLabel, prints label before writing.
	 */
	void printMeanProcTime(std::string label, char const *fileName, bool newLine, bool printLabel);

private:
	long detectedEvents;			// Events detected so far
	double processingTime;		// Sum of all processing times
	long numCalls;						// Number of function calls

};

#endif
